const add = (...args) => {
  let count = args.reduce((pre, cur) => {
    return pre + cur
  }, 0);//使用数组的reduce函数，第二个参数设置默认值
  const nextFun = (...args1) => {
    count = args1.reduce((pre, cur) => {
      return pre + cur
    }, count);
    return nextFun;//再次返回该方法用递归来实现无限累加
  }
  nextFun.toString = () => count;//重写函数的toString方法
  return nextFun;
}
console.log(add(1))//1
console.log("            ————————————————")
console.log(add(1)(2))//3
console.log("            ————————————————")
console.log(add(1)(2)(3))//6	
console.log("            ————————————————")
console.log(add(1)(2, 3))//6
console.log("            ————————————————")
console.log(add(1, 2)(3))//6
console.log("            ————————————————")
console.log(add(1, 2, 3))//6
let aa = add(1, 2, 3)(1, 2, 3)(1, 2, 3)(1, 2, 3)(1, 2, 3)(1, 2, 3)

console.log(aa + 1)
